#ifndef FVIDEODECODE_H
#define FVIDEODECODE_H

#include "blockingqueue.h"

#include <QThread>

extern "C" {
#include <libavutil/frame.h>
}

Q_DECLARE_METATYPE(AVFrame)

struct AVCodec;
struct AVCodecContext;
struct AVPacket;
struct AVStream;
class FVideoDecode : public QThread
{
    Q_OBJECT
public:
    explicit FVideoDecode(QObject *parent = nullptr);
    ~FVideoDecode();

    void addAVPacket(AVPacket *packet);
    bool initAVStream(AVStream *pAVStream);

signals:
    void sigYuv(AVFrame *pAVFrame); //显示一帧Yuv图像

protected:
    void run();

private:
    BlockingQueue<AVPacket *> m_queue;
    BoundedBlockingQueue<AVPacket *> m_queue2 {3};

    AVCodec *m_pAVCodec {nullptr};
    AVCodecContext *m_pAVDecoderCtx {nullptr};
    AVStream *m_pAVStream {nullptr};
};

#endif // FVIDEODECODE_H
